      Subroutine STATISTICS
      include "param.fi"
      include "common.fi"

      Integer I, FNUM

      ! Max values
      UMax = 0.0
      PMax = 0.0
      Do I = 1, NTOT3T
        If (SQRT(U1(I)*U1(I) + U2(I)*U2(I) + U3(I)*U3(I)).GT.UMax) Then
            UMax = SQRT(U1(I)*U1(I) + U2(I)*U2(I) + U3(I)*U3(I))
        Endif
        If (ABS(P(I)).GT.PMax) PMax = ABS(P(I))
      Enddo

      ! Total Kinetic Energy
      ENER = 0.0
      Do I = 1, NTOT3T
        ENER = ENER + 0.5 * Rho(I) * Weight(I) * 
     &       ( U1(I)*U1(I) + U2(I)*U2(I) + U3(I)*U3(I) )
      Enddo

      ! Total Potential Energy
      PTTL = 0.0
      Do I = 1, NTOT3T
        PTTL = PTTL + cGAMMA/(cGAMMA-1.0) * P(I) / Rho(I) +
     &         CSON * CSON * RDENSITY / Rho(I) / (cGAMMA - 1.0) 
      Enddo

      End Subroutine

C================================================================
      Subroutine STATISTICS1
      include "param.fi"
      include "common.fi"
      Integer I

      ! Calculate Vortex in 2D case
      If (DIMM .EQ. DIMM2D) Then

        If (ALE .NE. ALEEuler .AND.
     &      ifDual .EQ. 0 .AND. tagRegroup .EQ. 0) Then
        If (tagBoundary .EQ. BdrPeriodic) Then
          Call Grad(U1, DU1DX, DU1DY, DU1DZ)
          Call Grad(U2, DU2DX, DU2DY, DU2DZ)
          Call Grad(U3, DU3DX, DU3DY, DU3DZ)
        Else
          Call Grad_Ghost(U1, DU1DX, DU1DY, DU1DZ,1)
          Call Grad_Ghost(U2, DU2DX, DU2DY, DU2DZ,2)
          Call Grad_Ghost(U3, DU3DX, DU3DY, DU3DZ,3)
        Endif
        Endif

        Do I = 1, NP2
          VORTEX(I) = DU3DX(I) - DU1DZ(I)
        Enddo
      Endif

      End Subroutine
